﻿<!-- 教材管理-教研室审核 -->
<template>
    <div>
        <!-- 添加按钮 -->
        <div class="btn-add">
            <button type="button" class="btn btn-success btn-lg" @click="xzjc('1')"><i class="iconfont icon-chenggong ft12 mr5"></i>审核</button>
            <button type="button" class="btn btn-danger btn-lg" @click="xzjc('0')"><i class="iconfont icon-chexiao ft12 mr5"></i>取消审核</button>
        </div>
        <!-- 按条件选择 -->
        <div class="tab-filter-type ">

            <div class="col-xs-3 padding20">
                <div class="input-group" style="margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">学期</button>
                    </div>
                    <base-xq :pzoption="query.xq"></base-xq>

                </div>
            </div>


            <div class="col-xs-3 padding20">
                <div class="input-group" style="margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">教材选用状态</button>
                    </div>
                    <el-select placeholder="选用状态" size="mini" v-model="query.xzzt" class="form-control filter" style="height: 34px;padding:0px">
                        <el-option label="已选教材" value="0"></el-option>
                        <el-option label="未选教材" value="1"></el-option>

                    </el-select>

                </div>
            </div>
        </div>
        <div class="default-tab ft14  hover-btn" style="overflow-x: inherit;padding:20PX;padding-top:10px">
            <base-table :pzoption="tableop" @selection-change="handleSelectionChange">
            </base-table>
        </div>



        <!-- 表格 -->



    </div>
</template>

<script>
const { debug } = require("console");

    module.exports = {
        props: ['pdata'],
        components: {
            'base-table': httpVueLoader('/ViewV5/Base/Vue/Table.vue'),
            'base-xq': httpVueLoader('/ViewV5/AppPage/QJJW/component/conxq.vue'),
        },
        data: function () {
            return {
                search: "",
                kcdm: "",
                jssl: 0,
                jcdataset: [],
                query: {
                    zc: "1",
                    xzzt: "0",
                    xq: { value: "" },
                },
                js: { value: "" },
                alldata: [],
                seljc: { jcmc: "", isbn: "" },
                tableop: {
                    title: "教材选用信息",
                    issel: true,
                    iscz: false,
                    height: 450,
                    isxh: true,
                    dataset: [],
                    loading: true,
                    multipleSelection: [],
                    dtcxdata: [{ cxname: "年级", cxzd: "nj", cxdata: "", cal: "0", datatype: "1", dtsource: [], val: "" }, { cxname: "教研室名称", cxzd: "jysmc", cxdata: "", cal: "0", datatype: "1", dtsource: [], val: "" }, { cxname: "班级系部名称", cxzd: "xbmc", cxdata: "", cal: "0", datatype: "1", dtsource: [], val: "" }],
                    collist: [
                        { colid: "jysmc", colname: "教研室名称", isshow: true, istip: true },
                        { colid: "kcmc", colname: "课程名称", isshow: true, istip: true },
                        { colid: "kcdm", colname: "课程代码", isshow: true, istip: true },
                        { colid: "nj", colname: "年级", isshow: true, istip: true },
                        { colid: "bj", colname: "班级", isshow: true, istip: true  },
                        { colid: "bjrs", colname: "班级人数", isshow: true, istip: true  },
                        { colid: "jysshqk", colname: "教研室审核", isshow: true, istip: true },
                        { colid: "jsmc", colname: "上课教师", isshow: true, istip: true },
                        { colid: "jcmc", colname: "选定教材名称", isshow: true, istip: true, width: 160 },
                        { colid: "jsyssl", colname: "教师用书数量", isshow: true, istip: true },
                        { colid: "jcdm", colname: "ISBN", isshow: true, istip: true  },
                        { colid: "bzz", colname: "编者", isshow: true, istip: true },
                        { colid: "nf", colname: "出版年月", isshow: true, istip: true},
                        { colid: "dj", colname: "单价", isshow: true, istip: true},
                        { colid: "bs", colname: "版次", isshow: true, istip: true },

                    ]
                }
            }
        },
        methods: {
            handleSelectionChange(val) {
                this.tableop.multipleSelection = val;
            },
            seljcf: function (jc) {
                this.seljc = jc;
            },
            xzjc: function (shzt) {
                var pro = this;
                if (pro.query.xzzt=='1') {
                    this.$notify.error({
                        title: '错误',
                        message: '未选教材的信息无法进行审核操作'
                    });
                    return;
                }
                var ids = [];
                for (var i = 0; i < this.tableop.multipleSelection.length; i++) {
                    ids.push(this.tableop.multipleSelection[i].xyid);
                }
                if (ids.length == 0) {
                    this.$notify.error({
                        title: '错误',
                        message: '至少需要选择一条数据才能操作'
                    });
                    return;
                }
                $.getJSON('/API/VIEWAPI.ashx?Action=JCGL_SHJYSSHDATA', { P1: pro.query.xq.value, idns: ids.join(), shzt: shzt }, function (resultData) {
                    if (!resultData.ErrorMsg) {
                        pro.$notify({
                            title: '成功',
                            message: '操作成功',
                            type: 'success'
                        });
                        pro.querydata();
                    }
                })

            },
            querydata: function () {
                var pro = this;
                pro.tableop.loading = true;
                $.getJSON('/API/VIEWAPI.ashx?Action=JCGL_GETJYSSHDATA', { P1: pro.query.xq.value }, function (resultData) {
                    if (!resultData.ErrorMsg) {
                        debugger;
                        pro.alldata = resultData.Result;
                        if (pro.query.xzzt == '0') {
                            var ssdata = _.filter(resultData.Result, function (obj) {
                                return obj.xyid;
                            })
                            pro.tableop.dataset = ssdata;
                        }
                        if (pro.query.xzzt == '1') {
                            var ssdata = _.filter(resultData.Result, function (obj) {
                                return !obj.xyid;
                            })
                            pro.tableop.dataset = ssdata;
                        }

                        pro.tableop.loading = false;

                    }
                })

            },

            InitWigetData: function () {
                this.querydata();
            },
        },
        watch: {
            'query': { //深度监听，可监听到对象、数组的变化
                handler(newV, oldV) {
                    var chi = this;
                    if (newV) {
                        chi.querydata();
                    }
                },
                deep: true
            }
        },
        mounted: function () {
            var pro = this;
            pro.$nextTick(function () {
                //pro.InitWigetData();
            })

        }
    };
</script>